package com.linzm.template;

/**
 * @Author zimingl
 * @Date 2023/5/4 22:44
 * @Description: main
 */
public class Main {
    final static Object lock = new Object();
    public static void main(String[] args) {
        Milk milk = new Milk();
        for (int i = 0; i < 100; i++) {
            int finalI = i;
            new Thread(() -> {
                synchronized (lock) {
                    milk.setCount(finalI);
                    milk.setName("蒙牛");
                    milk.setPrice("3.99￥");
                    milk.template();
                    String name = Thread.currentThread().getName();
                    System.out.println("=======" + name);
                }

            }, "thread" + finalI).start();
        }
    }
}
